package com.ajx.cube.common.api;

import android.util.Log;

import com.ajx.core.net.rest.exception.ApiException;
import com.ajx.core.net.rest.observer.HttpObserver;

import java.util.logging.Logger;

import javax.security.auth.login.LoginException;

import io.reactivex.disposables.Disposable;

/**
 * Created by lai on 2017/12/5.
 */

public abstract class ExampleObserver<T> extends HttpObserver<T> {
    private static final String TAG = "ExampleObserver";
    public static final String INVALID_TOKEN="-1";
    public static final String EMPTY_OR_FAIL="2";
    public static final String SERVER_ERROR="-5";
    @Override
    protected void onStart(Disposable d) {

    }



    private void handError(String result, String message) {
        switch (result) {
            case INVALID_TOKEN:
                Log.e(TAG, "handError: INVALID_TOKEN" );
                break;
            case EMPTY_OR_FAIL:
                onEmptyOrFail(message);
                break;
            case SERVER_ERROR:
            default:
                onSeverError();
                break;
        }
    }

    protected abstract void onSeverError();

    protected abstract void onEmptyOrFail(String message);



    @Override
    public void onComplete() {

    }
}
